package April._22.work4;

public class FileUpdate implements Runnable {
    public int fileSize = 100;

    @Override
    public void run() {
        boolean flag=true;
        while (flag) {
            synchronized (this) {
                if (fileSize > 0) {
                    try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println(Thread.currentThread().getName() + " 下载了1M 还剩：" + (--fileSize));
                }else{
                    flag=false;
                }
            }

        }

    }
}
